package com.kfm.base.io.b;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Demo08 {

    public static void main(String[] args) {
        /**
         * 将 d://temp/可惜没如果.mp4 复制到 d:/io/可惜没如果.mp4
         */
        try {
            FileInputStream fis = new FileInputStream("d://temp/可惜没如果.mp4");
            FileOutputStream fos = new FileOutputStream("d:/io/可惜没如果.mp4");

//            byte[] bytes = new byte[8192];
//            int size;
//            while( (size = fis.read(bytes)) != -1){
//                fos.write(bytes, 0, size);
//            }

//            byte[] bytes = fis.readAllBytes();
//
//            fos.write(bytes);

            fis.transferTo(fos);


            fos.close();
            fis.close();

        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
